```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java并发模型与内存模型深入解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-bg {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .article-content {
            max-width: 900px;
            margin: 0 auto;
        }
        .section-card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .section-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
        }
        .code-block {
            font-family: 'Courier New', Courier, monospace;
            background-color: #f8f9fa;
            border-left: 4px solid #667eea;
            padding: 1rem;
            border-radius: 0 4px 4px 0;
            position: relative;
        }
        .code-block::before {
            content: attr(data-lang);
            position: absolute;
            top: 0;
            right: 1rem;
            font-size: 0.8rem;
            color: #6c757d;
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 3.5rem;
            line-height: 1;
            margin: 0.2rem 0.5rem 0 0;
            color: #667eea;
            font-weight: 700;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <header class="hero-bg text-white py-20 px-4">
        <div class="container mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">Java并发编程的艺术</h1>
            <p class="text-xl md:text-2xl mb-8 max-w-2xl mx-auto">深入解析并发模型与内存模型的实现原理</p>
            <div class="flex justify-center space-x-4">
                <a href="#concurrent-model" class="px-6 py-3 bg-white text-blue-700 font-medium rounded-lg hover:bg-blue-50 transition">并发模型</a>
                <a href="#memory-model" class="px-6 py-3 bg-transparent border-2 border-white text-white font-medium rounded-lg hover:bg-white hover:text-blue-700 transition">内存模型</a>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="py-12 px-4">
        <div class="article-content">
            <p class="text-xl text-gray-600 mb-12 drop-cap">Java的并发模型和内存模型是多线程编程的基石，理解这两者的实现原理和执行流程对于编写高效、线程安全的并发程序至关重要。</p>

            <!-- Concurrent Model Section -->
            <section id="concurrent-model" class="mb-16">
                <div class="flex items-center mb-8">
                    <div class="w-12 h-1 bg-blue-500 mr-4"></div>
                    <h2 class="text-3xl font-bold font-serif">Java并发模型概述</h2>
                </div>
                
                <div class="grid md:grid-cols-2 gap-8 mb-12">
                    <div class="bg-white p-6 rounded-xl shadow-md section-card">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-3">
                                <i class="fas fa-code-branch text-lg"></i>
                            </div>
                            <h3 class="text-xl font-semibold">线程模型基础</h3>
                        </div>
                        <p class="text-gray-700">Java的并发模型基于操作系统的线程模型，JVM通过多线程来实现并发编程。Java的线程管理是通过<code class="bg-gray-100 px-1 rounded">java.lang.Thread</code>类来实现的，而线程的调度则由操作系统负责。</p>
                    </div>
                    
                    <div class="bg-white p-6 rounded-xl shadow-md section-card">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center text-purple-600 mr-3">
                                <i class="fas fa-layer-group text-lg"></i>
                            </div>
                            <h3 class="text-xl font-semibold">核心组件</h3>
                        </div>
                        <ul class="text-gray-700 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-blue-500"></i>
                                <span><strong>Thread类</strong>：线程的基础类，管理创建、启动和终止</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-blue-500"></i>
                                <span><strong>Executor框架</strong>：高效的线程池管理方案</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-blue-500"></i>
                                <span><strong>ForkJoinPool</strong>：使用工作窃取算法实现任务并行化</span>
                            </li>
                        </ul>
                    </div>
                </div>

                <!-- Thread Lifecycle -->
                <div class="mb-12">
                    <h3 class="text-2xl font-semibold mb-6 flex items-center">
                        <i class="fas fa-life-ring text-blue-500 mr-3"></i>
                        线程的生命周期与状态转换
                    </h3>
                    
                    <div class="bg-white p-6 rounded-xl shadow-md mb-6">
                        <div class="mermaid">
                            stateDiagram-v2
                                [*] --> NEW
                                NEW --> RUNNABLE: start()
                                RUNNABLE --> BLOCKED: 等待锁
                                RUNNABLE --> WAITING: wait()
                                RUNNABLE --> TIMED_WAITING: sleep()
                                BLOCKED --> RUNNABLE: 获取锁
                                WAITING --> RUNNABLE: notify()
                                TIMED_WAITING --> RUNNABLE: 超时
                                RUNNABLE --> TERMINATED: 执行完成
                        </div>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-gray-800">线程状态</h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <span class="inline-block w-4 h-4 bg-blue-500 rounded-full mt-1 mr-2"></span>
                                    <span><strong class="font-mono">NEW</strong>：线程被创建但还未启动</span>
                                </li>
                                <li class="flex items-start">
                                    <span class="inline-block w-4 h-4 bg-green-500 rounded-full mt-1 mr-2"></span>
                                    <span><strong class="font-mono">RUNNABLE</strong>：线程已启动，等待调度</span>
                                </li>
                                <li class="flex items-start">
                                    <span class="inline-block w-4 h-4 bg-yellow-500 rounded-full mt-1 mr-2"></span>
                                    <span><strong class="font-mono">BLOCKED</strong>：等待锁资源</span>
                                </li>
                                <li class="flex items-start">
                                    <span class="inline-block w-4 h-4 bg-orange-500 rounded-full mt-1 mr-2"></span>
                                    <span><strong class="font-mono">WAITING</strong>：等待通知</span>
                                </li>
                                <li class="flex items-start">
                                    <span class="inline-block w-4 h-4 bg-red-500 rounded-full mt-1 mr-2"></span>
                                    <span><strong class="font-mono">TERMINATED</strong>：线程终止</span>
                                </li>
                            </ul>
                        </div>
                        
                        <div class="code-block" data-lang="Java">
public class Thread {
    private volatile int threadStatus;
    
    public void run() {
        threadStatus = RUNNING;
        // 执行任务
    }
}
                        </div>
                    </div>
                </div>
            </section>

            <!-- Memory Model Section -->
            <section id="memory-model" class="mb-16">
                <div class="flex items-center mb-8">
                    <div class="w-12 h-1 bg-purple-500 mr-4"></div>
                    <h2 class="text-3xl font-bold font-serif">Java内存模型(JMM)</h2>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md mb-8 section-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-memory text-purple-500 mr-3"></i>
                        JMM核心概念
                    </h3>
                    <p class="text-gray-700 mb-4">Java内存模型(Java Memory Model, JMM)定义了Java程序中多线程之间如何共享内存、如何保证内存一致性。JMM的核心目标是保证不同线程之间的可见性和操作的有序性。</p>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h4 class="font-medium mb-2 text-gray-800">主要规则</h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                    <span><strong>可见性</strong>：一个线程对共享变量的修改，对其他线程可见</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                    <span><strong>有序性</strong>：程序的执行顺序应当保持一致</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                    <span><strong>原子性</strong>：操作的不可分割性</span>
                                </li>
                            </ul>
                        </div>
                        
                        <div>
                            <h4 class="font-medium mb-2 text-gray-800">实现机制</h4>
                            <div class="flex flex-wrap gap-2">
                                <span class="px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm">volatile</span>
                                <span class="px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm">synchronized</span>
                                <span class="px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm">final</span>
                                <span class="px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm">CAS</span>
                                <span class="px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm">内存屏障</span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Memory Barrier Section -->
                <div class="mb-8">
                    <h3 class="text-2xl font-semibold mb-6 flex items-center">
                        <i class="fas fa-random text-purple-500 mr-3"></i>
                        内存屏障与指令重排
                    </h3>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <p class="text-gray-700 mb-4">指令重排是JVM为了优化性能可能会对指令执行顺序进行调整，可能导致程序的执行顺序不同于代码的顺序。内存屏障是一种特殊的CPU指令，用于防止特定的操作被重排，保证操作的有序性。</p>
                            
                            <div class="bg-blue-50 p-4 rounded-lg border-l-4 border-blue-500">
                                <h4 class="font-medium text-blue-800 mb-2">volatile的作用</h4>
                                <p class="text-blue-700">volatile关键字会在读取或写入变量时插入内存屏障，保证读取到的是最新的值，并防止指令重排序。</p>
                            </div>
                        </div>
                        
                        <div class="code-block" data-lang="Java">
private volatile int sharedVariable;

public void updateSharedVariable() {
    sharedVariable = 42;  // 对sharedVariable的写操作会在底层插入内存屏障
}
                        </div>
                    </div>
                </div>
                
                <!-- Synchronized Section -->
                <div class="mb-8">
                    <h3 class="text-2xl font-semibold mb-6 flex items-center">
                        <i class="fas fa-lock text-purple-500 mr-3"></i>
                        synchronized的实现与锁机制
                    </h3>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <p class="text-gray-700 mb-4"><code class="bg-gray-100 px-1 rounded">synchronized</code>是Java中最常用的同步机制，它确保多个线程之间对共享资源的访问是互斥的，避免了数据不一致的情况。</p>
                            
                            <div class="space-y-3">
                                <div class="flex items-start">
                                    <div class="w-8 h-8 rounded-full bg-purple-100 flex items-center justify-center text-purple-600 mr-3 flex-shrink-0">
                                        <i class="fas fa-key"></i>
                                    </div>
                                    <div>
                                        <h4 class="font-medium text-gray-800">监视器锁</h4>
                                        <p class="text-gray-600 text-sm">每个Java对象都有一个关联的锁，线程通过获取锁来保证执行代码的互斥性</p>
                                    </div>
                                </div>
                                
                                <div class="flex items-start">
                                    <div class="w-8 h-8 rounded-full bg-purple-100 flex items-center justify-center text-purple-600 mr-3 flex-shrink-0">
                                        <i class="fas fa-sort-amount-up"></i>
                                    </div>
                                    <div>
                                        <h4 class="font-medium text-gray-800">锁升级</h4>
                                        <p class="text-gray-600 text-sm">JVM使用偏向锁、轻量级锁和重量级锁来优化锁的性能</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="code-block" data-lang="Java">
public synchronized void syncMethod() {
    // 线程执行时会获取当前对象的锁
}
                        </div>
                    </div>
                </div>
                
                <!-- Wait/Notify Section -->
                <div>
                    <h3 class="text-2xl font-semibold mb-6 flex items-center">
                        <i class="fas fa-comments text-purple-500 mr-3"></i>
                        线程间通信：wait/notify机制
                    </h3>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <p class="text-gray-700 mb-4"><code class="bg-gray-100 px-1 rounded">wait()</code>和<code class="bg-gray-100 px-1 rounded">notify()</code>方法是Java中最常用的线程通信机制，依赖于每个对象内置的监视器锁。</p>
                            
                            <div class="bg-purple-50 p-4 rounded-lg mb-4">
                                <div class="flex items-start">
                                    <div class="text-purple-600 mr-3">
                                        <i class="fas fa-info-circle"></i>
                                    </div>
                                    <div>
                                        <p class="text-purple-800"><code class="bg-purple-100 px-1 rounded">wait()</code>会释放当前线程持有的锁，并使线程进入等待状态，<code class="bg-purple-100 px-1 rounded">notify()</code>则会唤醒一个等待中的线程</p>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="space-y-2">
                                <div class="flex items-center">
                                    <div class="w-3 h-3 rounded-full bg-purple-500 mr-2"></div>
                                    <span class="font-mono text-sm">wait()</span>
                                </div>
                                <div class="flex items-center">
                                    <div class="w-3 h-3 rounded-full bg-purple-500 mr-2"></div>
                                    <span class="font-mono text-sm">notify()</span>
                                </div>
                                <div class="flex items-center">
                                    <div class="w-3 h-3 rounded-full bg-purple-500 mr-2"></div>
                                    <span class="font-mono text-sm">notifyAll()</span>
                                </div>
                            </div>
                        </div>
                        
                        <div class="code-block" data-lang="Java">
public synchronized void doWait() 
    throws InterruptedException {
    this.wait();  // 使当前线程挂起
}

public synchronized void doNotify() {
    this.notify();  // 唤醒一个等待线程
}
                        </div>
                    </div>
                </div>
            </section>
            
            <!-- Summary Section -->
            <section class="bg-gradient-to-r from-blue-50 to-purple-50 p-8 rounded-xl shadow-inner">
                <h2 class="text-2xl font-bold mb-6 text-center font-serif">关键概念总结</h2>
                
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <div class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mb-4 mx-auto">
                            <i class="fas fa-project-diagram text-xl"></i>
                        </div>
                        <h3 class="text-lg font-semibold text-center mb-3">并发模型</h3>
                        <ul class="text-sm text-gray-600 space-y-1">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-blue-500"></i>
                                <span>Thread类与线程状态</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-blue-500"></i>
                                <span>Executor框架</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-blue-500"></i>
                                <span>ForkJoinPool</span>
                            </li>
                        </ul>
                    </div>
                    
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <div class="w-12 h-12 rounded-full bg-purple-100 flex items-center justify-center text-purple-600 mb-4 mx-auto">
                            <i class="fas fa-brain text-xl"></i>
                        </div>
                        <h3 class="text-lg font-semibold text-center mb-3">内存模型</h3>
                        <ul class="text-sm text-gray-600 space-y-1">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-purple-500"></i>
                                <span>可见性与有序性</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-purple-500"></i>
                                <span>内存屏障</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-purple-500"></i>
                                <span>指令重排</span>
                            </li>
                        </ul>
                    </div>
                    
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <div class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600 mb-4 mx-auto">
                            <i class="fas fa-exchange-alt text-xl"></i>
                        </div>
                        <h3 class="text-lg font-semibold text-center mb-3">同步机制</h3>
                        <ul class="text-sm text-gray-600 space-y-1">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-indigo-500"></i>
                                <span>synchronized</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-indigo-500"></i>
                                <span>volatile</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1 mr-2 text-indigo-500"></i>
                                <span>wait/notify</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </section>
        </div>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-800 text-gray-300 py-8 px-4">
        <div class="container mx-auto text-center">
            <h3 class="text-xl font-medium mb-2">技术小馆</h3>
            <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition">http://www.yuque.com/jtostring</a>
            <div class="mt-4 flex justify-center space-x-4">
                <a href="#" class="w-8 h-8 rounded-full bg-gray-700 flex items-center justify-center hover:bg-gray-600 transition">
                    <i class="fab fa-github"></i>
                </a>
                <a href="#" class="w-8 h-8 rounded-full bg-gray-700 flex items-center justify-center hover:bg-gray-600 transition">
                    <i class="fab fa-twitter"></i>
                </a>
                <a href="#" class="w-8 h-8 rounded-full bg-gray-700 flex items-center justify-center hover:bg-gray-600 transition">
                    <i class="fab fa-linkedin-in"></i>
                </a>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'neutral',
            fontFamily: 'inherit',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```